'use strict';
exports.main = (event, context) => {
	//event为客户端上传的参数
	const db = uniCloud.database();
	const addImg = db.collection('opendb-news-favorite').where({
		user: event.user,
		url: event.url
	}).count();
	if (addImg.total > 0) {
		return {
			code: 400,
			msg: '已收藏！'
		}
	} else {
		db.collection('opendb-news-favorite').add({
			user: event.user,
			url: event.url
		})
		return {
			code: 200,
			msg: '收藏成功！'
		}
	}
};
